package com.tangyuan.ai.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tangyuan.ai.entity.dto.ExchangeFaceDTO;
import com.tangyuan.ai.entity.dto.ExchangeFacePageDTO;
import com.tangyuan.ai.entity.model.AiExchangeFace;
import com.tangyuan.ai.service.AiExchangeFaceService;
import com.tangyuan.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("ai/exchangeFace")
public class AiExchangeFaceController {


    @Autowired
    AiExchangeFaceService AiExchangeFaceService;

    @GetMapping("getUserPageExchangeFace")
    public Result<Page<AiExchangeFace>> getUserPageExchangeFace(@RequestHeader("userId") Long userId,
                                                                  @ModelAttribute ExchangeFacePageDTO dto){
        return Result.ok(AiExchangeFaceService.getUserPageExchangeFace(userId,dto));
    }
    @GetMapping("getExchangeFaceById")
    public Result<AiExchangeFace> getExchangeFaceById(@RequestHeader("userId") Long userId,
                                                      @RequestParam Long id) throws Exception {
        return Result.ok(AiExchangeFaceService.getExchangeFaceById(userId,id));
    }

    @PostMapping("saveExchangeFace")
    public Result saveExchangeFace(@RequestHeader("userId") Long userId,
                                   @RequestBody @Valid  ExchangeFaceDTO dto) {
        return Result.ok(AiExchangeFaceService.saveExchangeFace(userId,dto));
    }
}
